#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QLayout>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    // 垂直布局管理器
    QPushButton* bt1 = new QPushButton("按钮1");
    QPushButton* bt2 = new QPushButton("按钮2");
    QVBoxLayout* vlayout = new QVBoxLayout(this);
    vlayout->addWidget(bt1);
    vlayout->addWidget(bt2);

    // 水平布局管理器
    QPushButton* bt3 = new QPushButton("按钮1");
    QPushButton* bt4 = new QPushButton("按钮2");
    QHBoxLayout* hlayout = new QHBoxLayout(this);
    hlayout->addWidget(bt3);
    hlayout->addWidget(bt4);

    // 将水平layout添加到垂直vlayout
    vlayout->addLayout(hlayout);

}

Widget::~Widget()
{
    delete ui;
}

